/**
 * vue组件混入字典数据
 * @type {{install(*, *): void}}
 */
import {getDictData} from "@/api/dictApi";
const dictionary = {
    install(Vue, options) {
        // 全局混入
        Vue.mixin({
            data() {
                return {
                    dicts: {}
                }
            },
            filters: {
                getDictLabel(value,dictDatas) {
                    let label = 'undefined';
                    if (dictDatas instanceof Array && dictDatas) {
                        dictDatas.forEach(dictData => {
                            if (dictData.value === value.toString()) {
                                label = dictData.label
                            }
                        })
                    }
                    return label
                }
            },
            methods: {

            },
            created() {
                this.dicts = getDictData(this.$options.dicts)
            }
        })
    }
}

export default dictionary